package cn.scw.project.separate.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.aspectj.lang.annotation.Log;
import cn.scw.framework.aspectj.lang.enums.BusinessType;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.separate.domain.SaRecord;
import cn.scw.project.separate.service.SaRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Api(tags = "分账记录信息")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH + "/separate/record")
public class RecordController extends BaseController {

    @Resource
    private SaRecordService saRecordService;

    @ApiOperation("查询分账记录列表")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam Map<String, Object> params) {
        startPage();
        List<SaRecord> list = saRecordService.list(params);
        return getDataTable(list);
    }

    //    @ApiOperation("查询所有分账用户列表")
//    @GetMapping("/list/all")
//    public AjaxResult listAll(@RequestParam Map<String, Object> params) {
//        List<SaUser> list = saUserService.list(params);
//        return AjaxResult.success(list);
//    }
//
//    @ApiOperation("获取分账用户详细信息")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id) {
//        return AjaxResult.success(saUserService.select(id));
//    }
//
//    @ApiOperation("新增分账用户")
//    @Log(title = "分账用户", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(SaUser user) {
//        saUserService.save(user);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("修改分账用户")
//    @Log(title = "分账用户", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(SaUser user) {
//        saUserService.save(user);
//        return AjaxResult.success();
//    }
//
    @ApiOperation("删除分账用户")
    @Log(title = "分账用户", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        saRecordService.delete(ids);
        return AjaxResult.success();
    }
}
